/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jclaimtest;

import elaborate.tool.messenger.Contact;
import elaborate.tool.messenger.ContactListener;
import elaborate.tool.messenger.Message;
import elaborate.tool.messenger.MessageListener;
import elaborate.tool.messenger.MessengerSender;
import elaborate.tool.messenger.StringMessage;
import elaborate.tool.messenger.yahoo.YahooMessengerConnection;

/**
 *
 * @author lendle
 */
public class Test3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        YahooMessengerConnection conn=new YahooMessengerConnection();
        conn.connect("lendle.test", "len1028");
        conn.addMessageListener(new MessageListener(){

            @Override
            public void onMessageReceived(String sender, String receiver, Message message) {
                System.out.println("sender="+sender+", receiver="+receiver+", message="+message);
            }

        });
        
        conn.addContactListener(new ContactListener(){

            @Override
            public void onContactStatusChanged(Contact contact) {
                System.out.println("contact: "+contact.getId()+":"+contact.getStatus());
            }
        });
        MessengerSender sender=conn.getSender();
        sender.sendMessage("cherry8620", new Message[]{new StringMessage("hahaha"), new StringMessage("中文測試123456 :))")});
        //sender.sendMessage("cherry8620", new Message[]{new StringMessage("中文測試 123456 :))")});
        Thread.sleep(60000);
        conn.disconnect();
    }
}
